package com.qf.service.impl;

import com.qf.dao.UsersDao;
import com.qf.dao.UsersMapper;
import com.qf.entity.Users;
import com.qf.service.UsersService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;

@Service
public class UsersServiceImpl implements UsersService {

    @Resource
    private UsersDao usersDao;

    @Resource
    private UsersMapper usersMapper;

    @Override
    public List<Users> findAll() {
        return usersDao.findAll();
    }

    @Override
    public Users insert(Users users) {

        Users save = usersDao.save(users);
        System.out.println(save);
        return save;

    }

    @Override
    public String delete(String userId) {
        usersDao.deleteById(userId);
        return "success";
    }

    @Override
    public Users update(Users user) {
        Users users = usersDao.save(user);
        return users;
    }

    @Override
    public Users findOneById(String userId) {
        Users userByUid = usersMapper.getUserByUid(userId);
        System.out.println(userByUid);
        return userByUid;


    }
}
